package com.situ.day7;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManager {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Student> list = new ArrayList<>();
        while (true) {
            System.out.println("请输入学生id：");
            int id = scanner.nextInt();
            System.out.println("请输入学生姓名: ");
            String name = scanner.next();
            System.out.println("请输入年龄：");
            int age = scanner.nextInt();
            System.out.println("请输入性别：");
            String gender = scanner.next();
            Student student = new Student(id, name, age, gender);
            list.add(student);
            System.out.println("是否继续输入：0退出 1继续");
            int quit = scanner.nextInt();
            if (quit == 0) {
                break;
            }
        }
        for (Student student : list) {
            System.out.println(student);
        }

        while (true) {
            System.out.println("根据id查找：1");
            System.out.println("根据name查找：2");
            System.out.println("根据age查找：3");
            System.out.println("根据gender查找：4");
            System.out.println("退出：0");
            int type = scanner.nextInt();
            if (type == 0) {
                System.out.println("退出程序");
                break;
            }

            switch (type) {
                case 1:
                    System.out.println("请输入要查找的id：");
                    int id = scanner.nextInt();
                    for (Student student : list) {
                        if (id == student.getId()) {
                            System.out.println(student);
                        }
                    }
                    //没有找到任何一个符合条件的学生，打印：没有该id学生
                    break;
                case 2:
                    System.out.println("请输入要查找的name：");
                    String name = scanner.next();
                    for (Student student : list) {
                        if (name.equalsIgnoreCase(student.getName())) {
                            System.out.println(student);
                        }
                    }
                    //没有找到任何一个符合条件的学生，打印：没有该name学生
                    break;
                case 3:
                    break;
                case 4:
                    break;
                default:
                    System.out.println("default");
                    break;
            }
        }

    }
}
